// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.brest.managesambafilesharing;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

// Referenced classes of package com.funkyfresh.samba:
//            LOG

public class FileOps {

	public FileOps() {
	}

	public static final boolean canRead(String s) {
		boolean flag;
		if (!(new File(s)).canRead())
			flag = false;
		else
			flag = true;
		return flag;
	}

	public static final boolean canWrite(String s) {
		boolean flag;
		if (!(new File(s)).canWrite())
			flag = false;
		else
			flag = true;
		return flag;
	}

	public static final boolean fileExists(String s) {
		boolean flag;
		if (!(new File(s)).exists())
			flag = false;
		else
			flag = true;
		return flag;
	}

	public static final String getFileSize(String s) {
		File file = new File(s);
		String s1;
		if (!file.exists())
			s1 = null;
		else
			s1 = String.valueOf(file.length());
		return s1;
	}

	public static final String[] readFile(String s) {
		String as[] = null;
		String s1 = null;
		if (s != null && fileExists(s) && canRead(s)) {// goto _L2; else goto
														// _L1
			File file;
			StringBuilder stringbuilder;
			file = new File(s);
			stringbuilder = new StringBuilder();
			try {
				BufferedReader bufferedreader = new BufferedReader(
						new FileReader(file));
				// _L3:
				while ((s1 = bufferedreader.readLine()) != null) {
					if (s1 == null) {
						if (stringbuilder.toString().length() >= 1)
							as = stringbuilder.toString().split("\\n");
						continue; /* Loop/switch isn't completed */
					}
					stringbuilder.append(s1);
					stringbuilder.append('\n');
				}
				// goto _L3
			} catch (IOException ioexception) {
				LOG.e((new StringBuilder(" caught exception trying to read "))
						.append(file).append(" :")
						.append(ioexception.getMessage()).toString());
			}
			// if(true) goto _L1; else goto _L4
			// _L4:

		}
		// _L1:
		return as;
	}

	public static final boolean rmFile(String s) {
		File file = new File(s);
		boolean flag;
		if (file.exists() && !file.delete())
			flag = false;
		else
			flag = true;
		return flag;
	}

	public static final boolean writeFile(String s, String as[]) {
		boolean flag = true;
		if (s != null && as != null && as.length >= 1) {
			StringBuilder stringbuilder = new StringBuilder();
			int i = 0;
			do {
				label0: {
					if (i < as.length)
						break label0;
					File file = new File(s);
					try {
						BufferedWriter bufferedwriter = new BufferedWriter(
								new FileWriter(file));
						bufferedwriter.write(stringbuilder.toString(), 0,
								stringbuilder.length());
						bufferedwriter.close();
					} catch (IOException ioexception) {
						LOG.e((new StringBuilder(
								" caught exception trying to write "))
								.append(file).append(" :")
								.append(ioexception.getMessage()).toString());
						flag = false;
					}
				}
				if (true)
					continue;
				stringbuilder.append(as[i]);
				stringbuilder.append('\n');
				i++;
			} while (true);
		} else {
			flag = false;
		}
		return flag;
	}
}
